home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 2867 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.2 KB

  1. Path: prairienet.org!sjmccaug
  2. From: sjmccaug@prairienet.org (Scott J. McCaughrin)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Object with Interrupt Service Routine
  5. Date: 20 Jan 1996 03:52:26 GMT
  6. Organization: University of Illinois at Urbana
  7. Message-ID: <4dpotq$5lc@vixen.cso.uiuc.edu>
  8. References: <DL8B3G.MuB@mv.mv.com> <4d6imm$okq@newsbf02.news.aol.com>
  9. Reply-To: sjmccaug@prairienet.org (Scott J. McCaughrin)
  10. NNTP-Posting-Host: firefly.prairienet.org
  11.  
  12.  
  13. In a previous article, ENGR@GSSI.MV.COM (Michael Furman) says:
  14.  
  15. >In article <4d6imm$okq@newsbf02.news.aol.com>, awhang8367@aol.com says...
  16. >>
  17. >>  I have been struggling to create an object that handles hardware
  18. >>interrupt directly.  Particularly with the setvect function as it takes in
  19. >>pointers to interrupts 
  20. >>^^^^^^^^^
  21. >>and not to objects.  Two things I can do (and I have accomplished ther
  22. >>former):
  23. >>
  24. >>   1)  Use an interrupt service routine to call the object.
  25. >
  26. >If you mean "call nonstatic member function of the object" - why not. I see
  27. >only two problems:
  28.  
  29.  Since Mr. Furman admits to having accompished this goal, why belabor it?
  30.  
  31. >  1. - how to obtain pointer to the instance that corresponds to this 
  32. >       interrupt.
  33.  
  34.  Wrong -- what you wnat is a THIS ptr to the object containing the int function.
  35.  
  36. >  2. - size of current stack. If it is asynchronous interrupt - it may 
  37. >happend at any time and nobody can garantee you that you have a stack space
  38. >big enough for executing your function.
  39. >
  40.  
  41.   Then you should either use the calling program's stack or dynamically
  42.   allocate. Otherwise, each re-entrance re-inits your SP to the stack-top.
  43.  
  44. >>   2)  directly write the address of the member function to the Interrupt
  45. >>vector table
  46. >You can, but only for static member function (and it probably should be 
  47. >declared with "interrupt" keyword - but it, like other staff, highly CPU/OS
  48. >dependable). To call nonstatic member function you must supply pointer to the 
  49. >instance of your class (my problem "1").
  50.  
  51.  Not so -- just install your member function as a re-entrant TSR and
  52.  chain to the next handler.
  53.  
  54. >>
  55. >>  Both implementations seems to be very clumsy.  Does anyone know of a
  56. >>good way of doing it?  Any pointer or email interrupt will be greatly
  57. >>appreciated.
  58. >
  59.  Scott McC.
  60.  
  61.